﻿@{
    Layout = null;
}

<style>
    .tree-node-selected {
        background: #fff;
        color: #000000;
    }
</style>
<script type="text/javascript">
    var mainMenu;
    var mainTabs;

    $(function () {

        mainMenu = $('#mainMenu').tree({
            //url: '/api/sysmenu/menutree',
            parentField: 'ParentId',
            checkOnSelect: false,
            selectOnCheck: false,
            loadFilter: function (data) {
                if (data.IsSuccess) {
                    return data.Data
                } else {
                    return [];
                }
            },
            onClick: function (node) {
                if (node.Url) {
                    addTab(node.Name, (node.IconClass ? node.IconClass : 'icon-standard-application-form'), node.Url);
                }
            }
        });

        mainTabs = $('#mainTabs').tabs({
            fit: true,
            border: true,
            tools: [{
                iconCls: 'ext-icon-arrow_up',
                handler: function () {
                    mainTabs.tabs({
                        tabPosition: 'top'
                    });
                }
            }, {
                iconCls: 'ext-icon-arrow_left',
                handler: function () {
                    mainTabs.tabs({
                        tabPosition: 'left'
                    });
                }
            }, {
                iconCls: 'ext-icon-arrow_down',
                handler: function () {
                    mainTabs.tabs({
                        tabPosition: 'bottom'
                    });
                }
            }, {
                iconCls: 'ext-icon-arrow_right',
                handler: function () {
                    mainTabs.tabs({
                        tabPosition: 'right'
                    });
                }
            }, {
                text: '刷新',
                iconCls: 'ext-icon-arrow_refresh',
                handler: function () {
                    var panel = mainTabs.tabs('getSelected').panel('panel');
                    var frame = panel.find('iframe');
                    try {
                        if (frame.length > 0) {
                            for (var i = 0; i < frame.length; i++) {
                                frame[i].contentWindow.document.write('');
                                frame[i].contentWindow.close();
                                frame[i].src = frame[i].src;
                            }
                            if (navigator.userAgent.indexOf("MSIE") > 0) {// IE特有回收内存方法
                                try {
                                    CollectGarbage();
                                } catch (e) {
                                }
                            }
                        }
                    } catch (e) {
                    }
                }
            }, {
                text: '关闭',
                id: "btnTabToolsClose",
                iconCls: 'ext-icon-cross',
                handler: function () {
                    var index = mainTabs.tabs('getTabIndex', mainTabs.tabs('getSelected'));
                    var tab = mainTabs.tabs('getTab', index);
                    if (tab.panel('options').closable) {
                        mainTabs.tabs('close', index);
                    }
                }
            }, {
                iconCls: 'layout-button-up',
                handler: function () {

                    //$('#mainLayout').layout('collapse', 'north');

                    var northCol = $('#mainLayout .layout-panel-north');
                    if (northCol[0]) {

                        $('#mainLayout .layout-panel-north').toggle();

                        var hh = northCol.height();

                        if ($(this).find(".layout-button-up")[0]) {
                            $(this).linkbutton({ 'iconCls': 'layout-button-down' });

                            $('#mainLayout .layout-panel-west').css({ "top": "0px" });
                            $('#mainLayout .layout-panel-center').css({ "top": "0px" });

                        } else {
                            $(this).linkbutton({ 'iconCls': 'layout-button-up' });

                            $('#mainLayout .layout-panel-west').css({ "top": hh + "px" });
                            $('#mainLayout .layout-panel-center').css({ "top": hh + "px" });
                        }

                        $('#mainLayout').layout('resize');
                    }
                }
            }]
        });
    });

</script>

<div class="easyui-tabs" data-options="fit:true">
    <div title="导航菜单" data-options="iconCls:'icon-standard-application-view-tile',fit:true">
        <div id="westCenterLayout" class="easyui-layout" data-options="fit: true">
            <div data-options="region: 'center', border: false">

                @Html.Partial("TreeMenus")

            </div>
        </div>
    </div>
</div>
